package com.ls.controller.startbanner;

import com.ls.controller.startbanner.model.AddSBannerModel;
import com.ls.controller.startbanner.model.EditSBannerModel;
import com.ls.controller.startbanner.model.updateStatusModel;
import com.ls.service.IStartBannerService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Api(value = "启动页轮播图组相关PC接口", tags = "启动页轮播图组相关PC接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/startBanner")
@Slf4j
public class StartBannerController {
    private final IStartBannerService service;
    /** 轮播图列表 */
    @GetMapping("pageList")
    public ResultData pageList() {
        return service.pageList();
    }
    /** 新增轮播图 */
    @PostMapping("add")
    public ResultData add(@Valid @RequestBody AddSBannerModel model) {
        log.info("新增轮播图: {}", model);
        return service.add(model);
    }
    /** 编辑轮播图 */
    @PostMapping("edit")
    public ResultData edit(@Valid @RequestBody EditSBannerModel model) {
        return service.edit(model);
    }
    /** 删除轮播图  */
    @PostMapping("del")
    public ResultData del(@RequestParam @NotNull(message = "id不得为空") Integer sBannerId) {
        return service.del(sBannerId);
    }
    /**修改轮播图启用状态*/
    @PostMapping("updateStatus")
    public ResultData updateStatus(@Valid @RequestBody updateStatusModel model) {
        return service.updateStatus(model);
    }
}
